<template>
  <view class="index">
  <view  class="item" v-for="item of tops" :key="item._id"  @click="handleClick(item._id)">
     <img :src="item.pic" alt="">
     <view>{{item.title}}</view>
  </view>
  </view>
</template>

<script>
import Taro from "@tarojs/taro";
import axios from 'axios';
export default {
  data() {
    return {
      tops:[]
    }
  },
  created(){
    axios.get("http://124.70.134.133:7001/api/movie/top250").then((res) => {
      // console.log(res);
      this.tops = res.data.res
    });
  },
  methods:{
    handleClick(val){
    var id = val;
    Taro.navigateTo({ url: `/pages/name/index?id=${id}` });
  }
  }
}
</script>
<style>
.index{
  display:flex;
  flex-wrap: wrap;
  justify-content: space-around ;
}
.index .item>img{
  width: 280px;
  height: 350px;
}
.index .item taro-view-core{
  width: 280px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
</style>
